#!/usr/bin/perl
use strict;
use warnings;
use autodie;
# use Getopt::Std;

use Encode(qw(decode));

use Spreadsheet::WriteExcel;



# my %opts =('i', "brca44");

# getopts('i:f:nc:', \%opts);


$#ARGV < 1 and die (`basename "$0 in.txt out.xls"`);

my $tools_path = $ENV{'tools_path'};
my $lib = $tools_path . '/perl_module/Spreadsheet-WriteExcel-2.40/lib';
push (@INC, $lib);


my $workbook  = Spreadsheet::WriteExcel -> new($ARGV[$#ARGV]);
my $worksheet = $workbook->add_worksheet();





open (my $CVS, $ARGV[0]) or die "$!";
my $row = 0;
while (<$CVS>) {
	chomp;
	my @Fld = split('\t', $_);
	my $col = 0;
	foreach my $token (@Fld) {
			$worksheet->write_string($row, $col, decode('utf8',$token));
			$col++;
	}
	$row++;
}

close $CVS;


$workbook->close();
